from llmtcg.chat.tool import Function, FunctionParameters, NoInputParams
from pydantic import Field

from typing import Type
from datetime import datetime
from time import sleep


class SleepParameters(FunctionParameters):
    time: int = Field(description="time to sleep, counted by seconds")


class Sleep(Function[SleepParameters]):

    def get_function_name(self) -> str:
        return "SleepWaiter"

    def get_function_description(self) -> str:
        return "Wait for a given time period and then return."

    def get_parameter_schema(self) -> Type[SleepParameters]:
        return SleepParameters

    def call(self, args: SleepParameters) -> str:
        sleep(args.time)
        return f"All done, we have slept for {args.time} seconds."


class CurrentDatetime(Function[NoInputParams]):

    def get_function_name(self) -> str:
        return "TimePickler"

    def get_function_description(self) -> str:
        return "Return the current time and date information"

    def get_parameter_schema(self) -> Type[NoInputParams]:
        return NoInputParams

    def call(self, _: NoInputParams) -> str:
        now = datetime.now()
        now_date = now.strftime("%Y.%m.%d")
        now_time = now.strftime("%I:%M:%S %p")
        return f"Today is {now_date}, and the current time is {now_time}."
